﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OrganizedIN.DAL;
using OrganizedIN.BAL;
using OrganizedIN.BussinessServices;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using OrganizedIN.BAL.Common;

namespace OrganizedIN.UI.ToDo
{
    public partial class priortize_todos : System.Web.UI.Page
    {
        string strUserName;
        string strID = "";
        string strAction = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            strUserName = Session["UserID"].ToString();
            strID = Request.QueryString["ID"];
            strAction = Request.QueryString["Action"];

            if (!IsPostBack)
            {
                BindList();  
            }

            if (strAction == "Up" || strAction == "Down")
            {
                Common.Todo_Priority_Change(strID, strAction, strUserName);
                BindList();
            }            

        }

        public void BindList()
        {
            try
            {
                DataSet ds = new DataSet();
                ds = Common.Get_Todo_SearchResult(strUserName);
                gvTodoList.DataSource = ds.Tables[0];
                gvTodoList.DataBind();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    lblErrMsg.Text = "";
                }
                else
                {
                    lblErrMsg.Text = "No record(s) found.";
                }
            }
            catch (Exception ex)
            {
                lblErrMsg.Text = ex.ToString();
            }
        }       
       
    }
}
